Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[monitorlib, mock_uss] Add idempotent handler decorator #241

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

BenjaminPelletier
Copy link
Member

Due to #28, duplicate requests to mock_uss instances are occasionally observed. Prior to this PR, such duplicate requests were identified and rejected, but this causes CI to fail when it could actually succeed. This PR introduces a decorator that can be applied to idempotent Flask view handlers to cache responses according to request ID and then return the cached response instead of invoking the underlying handler when a duplicate request is received. This decorator is then applied to idempotent, mutating mock_uss endpoints. The result is that if a mock_uss response is lost (this appears to occasionally be the case in CI), a client retry will receive a response identical to the lost response (as if the client received the initial successful response).

@BenjaminPelletier BenjaminPelletier marked this pull request as ready for review October 11, 2023 20:46
@BenjaminPelletier BenjaminPelletier linked an issue Oct 12, 2023 that may be closed by this pull request
@@ -43,7 +43,7 @@ def __init__(
"""
self._lock = multiprocessing.RLock()
self._shared_memory = multiprocessing.shared_memory.SharedMemory(
create=True, size=capacity_bytes
create=True, size=capacity_bytes + 4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding a comment on why the additional 4 bytes are required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, constants are better than magic numbers -- fixed, thanks.

@BenjaminPelletier BenjaminPelletier merged commit 29377b1 into interuss:main Oct 13, 2023
9 checks passed
@BenjaminPelletier BenjaminPelletier deleted the idempotency branch October 13, 2023 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Phantom flight injection request in CI
2 participants